package com.loanapp.server.market.api.home.api;


import com.loanapp.server.market.api.home.hystrix.InformationApiFallbackFactory;
import com.loanapp.server.market.api.platform.entity.CmsComment;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(value = "loanapp-server-market-provider",path = InformationApi.mapping,fallbackFactory = InformationApiFallbackFactory.class)
public interface InformationApi{

    static String mapping="information";

    /***
     * 获取资讯列表
     * @param cmsChannel
     * @param page
     * @return
     */
    @PostMapping("getInformationList")
    List<Map<String, Object>> getInformationList(@RequestParam("cmsChannel") String cmsChannel, @RequestBody int[] page);

    /***
     * 获取资讯评论
     * @param informationId
     * @param page
     * @return
     */
    @PostMapping("getDiscussList")
    List<Map<String, Object>> getDiscussList(@RequestParam("informationId") String informationId, @RequestBody int[] page);

    /***
     * 保存评论
     * @param cmsComment
     * @return
     */
    @PostMapping("saveCmsDiscuss")
    Integer saveCmsDiscuss(@RequestBody CmsComment cmsComment);

    /***
     * 删除评论
     * @param discussId
     * @param informationId
     * @return
     */
    @PostMapping("deleteCmsDiscuss")
    Integer deleteCmsDiscuss(@RequestParam("discussId") String discussId, @RequestParam("informationId") String informationId);

    /***
     * 用户资讯/帖子浏览记录
     * @param visitType 访问类型 1^资讯 2^帖子
     * @param user
     * @return
     */
    @PostMapping("getCustomInformationVisit")
    List<Map<String, Object>> getCustomInformationVisit(@RequestBody int[] page,@RequestParam("visitType") String visitType,@RequestParam("user")  Long user);

    /***
     * 新增资讯/帖子浏览记录
     * @param informationId
     * @param visitType
     * @param user
     */
    @PostMapping("insertInformationVisit")
    void insertInformationVisit(@RequestParam("informationId") String informationId,@RequestParam("visitType") String visitType,@RequestParam("user") Long user);

    /***
     * 删除资讯/帖子浏览记录
     * @param visitType 类型 1^资讯 2^论坛
     * @param idStr 浏览记录
     * @param user
     */
    @PostMapping("deleteInformationVisit")
    void deleteInformationVisit(@RequestParam("visitType") String visitType,@RequestParam("idStr") String idStr,@RequestParam("user") Long user);

    /***
     * 资讯栏目列表
     * @param cmsChannel    [提额妙招、贷款技巧、贷款问答、芝麻提分]
     * @param page
     * @return
     */
    @PostMapping("getInformationBranchList")
    List<Map<String, Object>> getInformationBranchList(@RequestParam("cmsChannel") String cmsChannel,@RequestBody int[] page);

}
